namespace OracleInternal.TTC
{
	internal class TTCKeywordValuePair
	{
		internal int m_keyword;

		internal byte[] m_binaryValue;

		internal string m_textValueInString;

		internal TTCKeywordValuePair(int _keyword, string _textValue, byte[] _binaryValue)
		{
			m_keyword = _keyword;
			m_textValueInString = _textValue;
			m_binaryValue = _binaryValue;
		}

		internal void Marshal(MarshallingEngine mEngine)
		{
			if (m_binaryValue != null)
			{
				mEngine.MarshalUB2(0);
				mEngine.MarshalUB2(m_binaryValue.Length);
				mEngine.MarshalCLR(m_binaryValue, m_binaryValue.Length);
			}
			else if (!string.IsNullOrEmpty(m_textValueInString))
			{
				mEngine.MarshalUB2(0);
				byte[] array = mEngine.m_dbCharSetConv.ConvertStringToBytes(m_textValueInString, 0, m_textValueInString.Length);
				if (array != null && array.Length != 0)
				{
					mEngine.MarshalUB2(array.Length);
					mEngine.MarshalCLR(array, array.Length);
				}
			}
			else
			{
				mEngine.MarshalUB2(0);
				mEngine.MarshalUB2(0);
			}
			mEngine.MarshalUB2(m_keyword);
		}

		internal static TTCKeywordValuePair Unmarshal(MarshallingEngine mEngine)
		{
			int[] array = new int[1];
			string textValue = null;
			byte[] array2 = null;
			int num = mEngine.UnmarshalUB2();
			if (num != 0)
			{
				byte[] bytes = new byte[num];
				mEngine.UnmarshalCLR(bytes, 0, array);
				textValue = mEngine.m_dbCharSetConv.ConvertBytesToString(bytes, 0, array[0]);
			}
			int num2 = mEngine.UnmarshalUB2();
			if (num2 != 0)
			{
				array2 = new byte[num2];
				mEngine.UnmarshalCLR(array2, 0, array);
			}
			return new TTCKeywordValuePair(mEngine.UnmarshalUB2(), textValue, array2);
		}
	}
}
